package golang

func numSubarraysWithSum(nums []int, goal int) int {

	total := 0
	for i := 0; i < len(nums); i++ {
		tmpTotal:=0
		for j:=i;j<len(nums);j++{
			tmpTotal+=nums[j]
			if tmpTotal==goal{
				total++
			}else if tmpTotal>goal{
				break
			}
		}
	}

	return total
}

